In [19]:
import graphlab
In [20]:
song_data = graphlab.SFrame('song_data.gl/')
In [21]:
song_data.head()
Out[21]:
In [22]:
graphlab.canvas.set_target('ipynb')
In [23]:
song_data['song'].show()
In [24]:
len(song_data)
Out[24]:
In [25]:
users = song_data['user_id'].unique()
In [26]:
len(users)
Out[26]:
In [27]:
train_data,test_data = song_data.random_split(.8,seed=0)
In [28]:
popularity_model = graphlab.popularity_recommender.create(train_data,
user_id='user_id',
item_id='song')
In [29]:
popularity_model.recommend(users=[users[0]])
Out[29]:
In [30]:
popularity_model.recommend(users=[users[1]])
Out[30]:
In [31]:
personalized_model = graphlab.item_similarity_recommender.create(train_data,
user_id='user_id',
item_id='song')
In [54]:
personalized_model.recommend([users[0]])
Out[54]:
In [33]:
personalized_model.recommend(users=[users[1]])
Out[33]:
In [34]:
personalized_model.get_similar_items(['With Or Without You - U2'])
Out[34]:
In [35]:
personalized_model.get_similar_items(['Chan Chan (Live) - Buena Vista Social Club'])
Out[35]:
In [52]:
if graphlab.version[:3] >= "1.6":
model_performance = graphlab.compare(test_data, [popularity_model, personalized_model], user_sample=0.05)
graphlab.show_comparison(model_performance,[popularity_model, personalized_model])